package com.yangdage.service;

import com.yangdage.dao.TUserMapper;
import com.yangdage.model.TUser;
import com.yangdage.model.TUserExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;

@Service
public class TUserService {
    @Autowired
    TUserMapper tUserMapper;

    public List<TUser> selectByExample(TUserExample tUserExample){
        return tUserMapper.selectByExample(tUserExample);
    }

    @Async("asyncServiceExecutor")
    public List<TUser> selectByExampleAsync(TUserExample tUserExample){
        try {
            System.out.println(new Date()+"开始异步执行");
            TimeUnit.SECONDS.sleep(6);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(new Date()+"开始查询");
        return tUserMapper.selectByExample(tUserExample);
    }
}
